package com.bjc.platform.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "adm_authority")
public class AdmAuthority extends BaseObject implements Serializable {
	private Long id;
	private String resId;
	private String accessRange;
	private String permission;
	private String remark;
	private Long creator;
	private Date createTime;
	private Long updater;
	private Date updateTime;
	private boolean flag;

	private AdmRole admRole;

	@Id
	@Column(name = "id", columnDefinition="int")
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "res_id", nullable = false, length = 64)
	public String getResId() {
		return this.resId;
	}

	public void setResId(String resId) {
		this.resId = resId;
	}

	@Column(name = "access_range")
	public String getAccessRange() {
		return this.accessRange;
	}

	public void setAccessRange(String accessRange) {
		this.accessRange = accessRange;
	}

	@Column(name = "permission")
	public String getPermission() {
		return this.permission;
	}

	public void setPermission(String permission) {
		this.permission = permission;
	}

	@Column(name = "remark", length = 600)
	public String getRemark() {
		return this.remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@Column(name = "creator", nullable = false, columnDefinition="int")
	public Long getCreator() {
		return this.creator;
	}

	public void setCreator(Long creator) {
		this.creator = creator;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "create_time", nullable = false, length = 19)
	public Date getCreateTime() {
		return this.createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Column(name = "updater", columnDefinition="int")
	public Long getUpdater() {
		return this.updater;
	}

	public void setUpdater(Long updater) {
		this.updater = updater;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "update_time", length = 19)
	public Date getUpdateTime() {
		return this.updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	@Column(name = "flag", nullable = false)
	public boolean getFlag() {
		return this.flag;
	}

	public void setFlag(boolean flag) {
		this.flag = flag;
	}

	@ManyToOne
	@JoinColumn(name = "role_id")
	public AdmRole getAdmRole() {
		return admRole;
	}

	public void setAdmRole(AdmRole admRole) {
		this.admRole = admRole;
	}

	public boolean equals(Object o) {
		if (this == o)
			return true;
		if (o == null || getClass() != o.getClass())
			return false;

		AdmAuthority pojo = (AdmAuthority) o;
		if (resId != null ? !resId.equals(pojo.resId) : pojo.resId != null)
			return false;
		if (accessRange != null ? !accessRange.equals(pojo.accessRange)
				: pojo.accessRange != null)
			return false;
		if (permission != null ? !permission.equals(pojo.permission)
				: pojo.permission != null)
			return false;
		if (remark != null ? !remark.equals(pojo.remark) : pojo.remark != null)
			return false;
		if (creator != null ? !creator.equals(pojo.creator)
				: pojo.creator != null)
			return false;
		if (createTime != null ? !createTime.equals(pojo.createTime)
				: pojo.createTime != null)
			return false;
		if (updater != null ? !updater.equals(pojo.updater)
				: pojo.updater != null)
			return false;
		if (updateTime != null ? !updateTime.equals(pojo.updateTime)
				: pojo.updateTime != null)
			return false;

		return true;
	}

	public int hashCode() {
		int result = 0;
		result = 31 * result + (resId != null ? resId.hashCode() : 0);
		result = 31 * result
				+ (accessRange != null ? accessRange.hashCode() : 0);
		result = 31 * result + (permission != null ? permission.hashCode() : 0);
		result = 31 * result + (remark != null ? remark.hashCode() : 0);
		result = 31 * result + (creator != null ? creator.hashCode() : 0);
		result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
		result = 31 * result + (updater != null ? updater.hashCode() : 0);
		result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0);

		return result;
	}

	public String toString() {
		StringBuffer sb = new StringBuffer(getClass().getSimpleName());

		sb.append(" [");
		sb.append("id").append("='").append(getId()).append("', ");
		sb.append("resId").append("='").append(getResId()).append("', ");
		sb.append("accessRange").append("='").append(getAccessRange())
				.append("', ");
		sb.append("permission").append("='").append(getPermission())
				.append("', ");
		sb.append("remark").append("='").append(getRemark()).append("', ");
		sb.append("creator").append("='").append(getCreator()).append("', ");
		sb.append("createTime").append("='").append(getCreateTime())
				.append("', ");
		sb.append("updater").append("='").append(getUpdater()).append("', ");
		sb.append("updateTime").append("='").append(getUpdateTime())
				.append("', ");
		sb.append("flag").append("='").append(getFlag()).append("'");
		sb.append("]");

		return sb.toString();
	}

}
